﻿
@{
    ViewData["Title"] = "index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
    <link href="~/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="~/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="~/css/plugins/jsTree/style.min.css" rel="stylesheet" />
    <link href="~/css/animate.min.css" rel="stylesheet" />
    <link href="~/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        #dTree {
            border: 1px solid #ddd;
            margin-top: 10px;
            padding: 10px;
        }

        .jstree-open > .jstree-anchor > .fa-folder:before {
            content: "\f07c";
        }

        .jstree-default .jstree-icon.none {
            width: 0;
        }

        #jstree1 span {
            margin-left: 10px;
        }

        #jstree1 div {
            position: absolute;
            right: 0px;
            top: 0px;
        }

        #jstree1 .jstree-node {
            position: relative;
        }
        /*#jstree1 .jstree-node:hover { background-color: #DFF0D8; }*/
        .jstree-anchor:hover {
            background-color: #DFF0D8;
        }

            .jstree-anchor:hover > div {
                background-color: #DFF0D8;
            }
    </style>

}
<form id="form1" runat="server">
    <div id="dMain">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="ibox" style="margin-bottom: 0px;">
                <div class="ibox-title">
                    <h5>机构部门管理</h5>
                </div>
                <div class="ibox-content">
                    <div id="toolbar" class="dSearch">
                        <button class="btn btn-primary btn-sm" type="button" onclick="showPage('添加机构','@Url.Action("edit","Department",new { area="System"})',500,620,true)">添加机构</button>
                    </div>
                    <div id="dTree">
                        <div id="jstree1">
                            @await Component.InvokeAsync("RTW.Web.Component.DpetTreeList")
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>



</form>

@section scripts{
    <script src="~/js/jquery.min.js?v=2.1.4"></script>
    <script src="~/js/bootstrap.min.js?v=3.3.6"></script>

    <script src="~/js/My97DatePicker/WdatePicker.js"></script>
    <script src="~/js/plugins/layer/layer.min.js"></script>
    <script src="~/js/plugins/jsTree/jstree.min.js"></script>
    <script src="~/js/verification.js"></script>
    <script src="~/js/zuiCode.js"></script>


    <script type="text/javascript">
        $(function () {

            $("#dTree").css({ "min-height": GetHeight() - 139 });

            $("#jstree1").jstree({
                "core": { "check_callback": true },
                "plugins": ["types", "dnd"],
                "types": {
                    "default": { "icon": "fa fa-folder" },
                    "html": { "icon": "fa fa-file-code-o" },
                    "svg": { "icon": "fa fa-file-picture-o" },
                    "css": { "icon": "fa fa-file-code-o" },
                    "img": { "icon": "fa fa-file-image-o" },
                    "js": { "icon": "fa fa-file-text-o" }
                }
            });
            //加载功能树

            $("span.sDMName").parent().hover(function () {
                var DMID = $(this).find(".sDMName").attr("DMID");
                var WaterMarkPath = "\\WaterMark\\" + DMID + ".png";

                var l = $(this).offset().left + 20;//左边距
                var t = $(this).offset().top + 30;//上边距

                var htmlStr = "<img class=\"imgwm\" src=\"" + WaterMarkPath + "\" style=\"position:absolute;left:" + l + "px;top:" + t + "px;height:300px;border:1px solid #ddd;background-color:#eee;\" />";
                $("body").append(htmlStr);
            }, function () {
                $(".imgwm").remove();
            })

        })



        //删除部门及所有子机构
        function DelDepartment(_ID) {
            window.top._Confirm('确定要删除选中的机构及其所有子机构？', function () {
                $.ajax({
                    type: "post",
                    url: "DelDepartment",
                    dataType: "json",
                    async: false,
                    data: { ID: _ID },
                    success: function (msg) {
                        if (msg.result == 1) {
                            location.href = location.href;
                        }
                    }
                });
            })
        }
    </script>
}